package cn.test.demo.base_demo.service;

import cn.test.demo.base_demo.security.CurrentSetHolder;
import org.springframework.stereotype.Component;

/**
 * @author 王杨帅
 * @create 2018-04-29 17:19
 * @desc 权限校验服务类
 **/
@Component
public class AuthService {

    /**
     * 权限检查，如果用户不是 “admin" 就会报错
     */
    public void checkAccess() {
        String user = CurrentSetHolder.get();
        if (!"admin".equals(user)) {
            throw new RuntimeException("operation not allow.");
        }
    }
}

